// @ts-ignore
import './index.css'

// @ts-ignore
import 'antd/dist/antd.css'
import {Layout as AntDLayout, message} from 'antd';

import {Component} from 'react';

import CustomSider from "./Sider";
import CustomHeader from "./Header";
import CustomContent from "./Content";
import CustomFooter from "./Footer";

import {renewPrincipalIfExists, setPrincipal} from '../../utils/auth.util.tsx'

class Dashboard extends Component<any, any> {

    componentDidMount() {
        // ~ 全局校验登录并刷新凭证
        renewPrincipalIfExists()
            .then((principal) => setPrincipal(principal))
            .catch((error) => message.error(error + '，请重新登录').then(() => this.props.history.replace("/")))
    }

    render() {
        return (
            <>
                <AntDLayout className="dashboard">
                    <CustomSider/>

                    <AntDLayout>
                        <CustomHeader/>
                        <CustomContent/>
                        <CustomFooter/>
                    </AntDLayout>
                </AntDLayout>
            </>
        )
    }
}

export default Dashboard;
